package com.kauidao.manageweb.controller.dictionary;

import com.kauidao.manageweb.feign.dictionary.DictionaryFeignClient;
import com.kauidao.manageweb.feign.dictionary.DictionaryItemFeignClient;
import com.kuaidao.common.entity.JSONResult;
import com.kuaidao.common.entity.PageBean;
import com.kuaidao.sys.dto.dictionary.DictionaryItemReqDTO;
import com.kuaidao.sys.dto.dictionary.DictionaryItemResDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping("/dictionary/DictionaryItem")
@Slf4j
public class DictionaryItemController {

    @Autowired
    private DictionaryItemFeignClient dictionaryItemFeignClient;

    @RequestMapping("/itemListPage")
    public String itemListPage(HttpServletRequest request){
        log.info("----------------------------------------跳转到词条页面------------------------------------------------");
        String dicid = request.getParameter("dicid");
        String groupCode = request.getParameter("groupCode");
        request.setAttribute("dicid",dicid);
        request.setAttribute("groupCode",groupCode);
        return "dictionary/dicItemlistPage";
    }


    @ResponseBody
    @PostMapping("/queryDictionaryItems")
    public JSONResult<PageBean<DictionaryItemResDTO>> queryDictionaryItems(@RequestBody DictionaryItemReqDTO dictionaryItemReqDTO){

        JSONResult<PageBean<DictionaryItemResDTO>> dictionaryItemByPage = dictionaryItemFeignClient.findDictionaryItemByPage(dictionaryItemReqDTO);

        return dictionaryItemByPage;
    }



}
